package org.carabiner.harness;

import java.awt.Component;

import net.infonode.docking.SplitWindow;
import net.infonode.docking.View;
import net.infonode.docking.util.DockingUtil;

/**
 * A harness is used to test a GUI component (such as a JPanel). The harness
 * allows a user to verify whether or not a GUI component is correct.
 * 
 * <p>
 * Carabiner Testing Framework
 * </p>
 * <p>
 * Copyright: <a href="http://www.gnu.org/licenses/gpl.html">GNU Public License</a>
 * </p>
 * 
 * @author Ben Rady (benrady@gmail.com)
 * 
 * @see WindowHarness
 */
class ComponentHarness extends AbstractHarness
{
  private Component component;

  protected ComponentHarness(Component testSubject)
  {
    super(testSubject);
  }

  public void attach(Component testSubject)
  {
    super.attach(testSubject);
    component = testSubject;

    View view = new View("Component Viewer", null, component);
    DockingUtil.addWindow(view, getRootWindow());
    if (getRootWindow().getChildWindowCount() > 1)
    {
      getRootWindow().setWindow(
          new SplitWindow(true, getRootWindow().getWindow(), view));
    }
    getFrame().pack();
  }
}
